<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>领卷追溯</title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
    />
    <link rel="stylesheet" href="../layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="../style/admin.css" media="all"/>
    <link rel="stylesheet" href="../style/home.css" media="all"/>
    <script src="../layui/layui.js"></script>
    <style>
        html,
        body {
            width: 100%;
            height: 100%;
            margin: 0px;
            padding: 0px;
            border: 0px;
            overflow: hidden;
            background-color: #FFFFFF;
            /* overflow-x: scroll; */
        }

        .layui-form-item .layui-inline {
            padding-right: 0px;
            margin-right: 0px;
        }

    </style>
</head>
<body layadmin-themealias="default">
<div class="" style="padding: 0 20px">
    <table id="dataTable" lay-filter="dataTable" class="layui-table"></table>
</div>
<script id="operationBar" type="text/html">
    {{#  if(d.status=="0"){ }}
    <a lay-filter="return" href="#" lay-event="return">
        <i class="layui-icon layui-icon-refresh p3" title="回收"></i>
    </a>
    {{#  } }}
</script>
<script id="statusTpl" type="text/html">
    {{#  if(d.status=="1"){ }}
    <i class="layui-icon layui-icon-ok"></i>
    {{#  } }}
</script>
<script>
    var $ = layui.$;
    table = layui.table;
    table.render({
        elem: '#dataTable'
        , url: '/archives/getReceiveLog?archivesId=' + '[[${archivesId}]]'
        , method: 'get'
        , cellMinWidth: 50
        , page: true
        , limit: 50
        , height: 'full-65'
        , loading: true
        , size: 'sm'
        , cols: [
            [ //标题栏
                {field: 'status', title: '还卷', fixed: 'left', width: 40, templet: "#statusTpl"},
                {field: 'userName', title: '领用人', fixed: 'left', width: 80},
                {field: 'receiveTime', title: '领用时间', width: 135},
                {field: 'returnTime', title: '还卷时间', width: 135},
                {field: 'returner', title: '还卷操作人', width: 90},
                {fixed: 'right', title: '操作', width: 60, toolbar: '#operationBar'}
            ]
        ],
    });

    //监听工具条
    table.on('tool(dataTable)', function (obj) {
        var data = obj.data;
        switch (obj.event) {
            case 'return':
                //归还
                parent.layer.confirm("确定要回收该档案吗？", function (index) {
                    $.ajax({
                        url: "./returnWorkReceive", //url
                        contentType: "application/json",
                        dataType: "json", //数据格式
                        type: "POST", //请求方式
                        async: false, //是否异步请求
                        data: JSON.stringify({id: data.id, pid: data.pid, tid: data.tid}),
                        success: function (result) {
                            if (result.code == 0) {
                                table.reload("dataTable");
                                parent.layer.msg(result.message, {icon: 1});
                            } else {
                                parent.layer.alert(result.message, {icon: 2});
                            }
                        },
                    });
                    return false;
                });
                break;
        }
    });

</script>
</body>
</html>